import prime_generator


def _generate_digits(value: int):
    assert value > 0
    while value > 0:
        yield value % 10
        value //= 10


def _main():
    primes = prime_generator.generate_prime_list(4444)
    allowed_digits = [1, 2, 3, 4]

    def judge1(value: int):
        assert value > 0
        digits = list(_generate_digits(value))
        digits_count = [digits.count(d) for d in allowed_digits]
        return sum(digits_count) == len(digits) and all([c <= 1 for c in digits_count])

    def judge2(value: int):
        assert value > 0
        digits = list(_generate_digits(value))
        digits_count = [digits.count(d) for d in allowed_digits]
        return sum(digits_count) == len(digits)

    print([i for i in primes if judge1(i)])
    print([i for i in primes if judge2(i)])


if __name__ == "__main__":
    _main()
